import Vue from 'vue'
import App from './App'

// vuex
import store from './store'

// 引入全局uView
import uView from '@/uni_modules/uview-ui'

import mixin from './common/mixin'

//定义全局布局组件
import scrollCom from '@/components/scroll-com/scroll-com.vue';
Vue.component('scroll-com', scrollCom);

Vue.prototype.$store = store

Vue.config.productionTip = false

App.mpType = 'app'
Vue.use(uView)

// #ifdef MP
// 引入uView对小程序分享的mixin封装
const mpShare = require('@/uni_modules/uview-ui/libs/mixin/mpShare.js')
Vue.mixin(mpShare)
// #endif

Vue.mixin(mixin)
// 全局路由守卫
const request = ['navigateTo','redirectTo','switchTab','navigateBack']
request.forEach((item)=>{
	uni.addInterceptor(item, {
	  invoke(args) {
		  const doctorId = uni.getStorageSync('doctorId');
		  if(args.url !== '/pages/login/login'&&args.url !=='/pages/register/register'){
			  if(!doctorId){
				  uni.reLaunch({
				    url: '/pages/login/login'
				  });
				  return false;
			  }
		  }
	    return true;
	  }
	});
})

const app = new Vue({
    store,
    ...App
})
// 引入请求封装
require('./util/request/index')(app)

app.$mount()
